<include file="/public/header" />
<!-- 重定位style -->
<style>
.layui-table-cell {height: 35px;line-height: 35px;}
.layui-table, .layui-table-view{margin-top: 0px;}
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <!-- // 默认操作按钮 -->
        <div class="layui-card-header layadmin-card-header-auto ">
        <div class="layui-form">
            <div class="layui-form-item">

            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select name="status">
                        <option value="">{:__('按状态查询')}</option>
                        <option value="2" >{:__('正常')}</option>                                 
                        <option value="1" >{:__('关闭')}</option>                             
                    </select>
                </div>  
            </div>
            <div class="layui-inline">
                <div class="layui-form-label">{:__('事件查询')}</div>
                <div class="layui-input-inline "><input name="title" class="layui-input" type="text" placeholder="{:__('事件名称')}"/></div>
            </div>
            <div class="layui-inline" >
                <!-- // 默认搜索 -->
                <button class="layui-btn icon-btn" lay-filter="formSearch" lay-submit>
                    <i class="layui-icon layui-icon-search"></i>{:__('搜索')}
                </button>
                
                <!-- // 打开添加页面 -->
                <button class="layui-btn icon-btn" lay-open="" lay-title="数据事件" lay-area="680px" lay-url="#editforms" >
                    <i class="layui-icon layui-icon-add-1"></i>{:__('添加')}
                </button>
            </div>
            </div>
        </div> 

        </div>

        <!-- // 创建数据表实例 -->
        <table id="lay-tableList" lay-filter="lay-tableList"></table>        
    </div>
</div>

<!-- // 添加编辑数据 -->
<script type="text/html" id="editforms" >
<div class="layui-fluid layui-bg-white">
    <form class="layui-form" lay-filter="editforms" >
    <input type="text" name="id" hidden="">
    <div class="layui-form-item">
        <label class="layui-form-label"><font color="red">* </font>{:__('事件名称')}</label>
        <div class="layui-input-inline">
            <input name="title" placeholder="{:__('请输入事件名称')}" type="text" class="layui-input"   />
        </div>
        <label class="layui-form-label">{:__('排序号')}</label>
        <div class="layui-input-inline">
            <input name="sort" placeholder="{:__('默认自动生成')}" type="number" class="layui-input"   />
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">{:__('事件类库')}</label>
        <div class="layui-input-inline">
            <input name="class" placeholder="{:__('请输入事件类/方法')}" type="text" class="layui-input"  lay-verify="required" />
        </div>
        <label class="layui-form-label"><font color="red">* </font>{:__('事件状态')}</label>
        <div class="layui-input-inline">
            <input name="status" type="radio" value="1" title="{:__('正常')}" checked/>
            <input name="status" type="radio" value="0" title="{:__('停用')}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"><font color="red">* </font>{:__('触发位置')}</label>
        <div class="layui-input-inline" style="width: 500px">
            <input name="trigger" placeholder="{:__('请输入触发位置')}" type="text" class="layui-input"  />
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">{:__('事件简介')}</label>
        <div class="layui-input-inline" style="width: 500px">
            <input name="content" placeholder="{:__('请输入事件简介')}" type="text" class="layui-input"  />
        </div>
    </div>

    <div class="layui-footer layui-form-item layui-center "  >
        <button class="layui-btn layui-btn-primary" type="button" sa-event="closePageDialog" >{:__('取消')}</button>
        <button class="layui-btn" lay-add="{:url('/system.pluginhook/add')}" lay-edit="{:url('/system.pluginhook/edit')}" lay-filter="submitPage"  lay-submit>{:__('提交')}</button>
    </div>
    </form>
</div>
</script>

<!-- // 列表状态栏 -->
<script type="text/html" id="columnStatus">
    <input type="checkbox" lay-filter="switchStatus" lay-url="{:url('/system.pluginhook/status')}" value="{{d.id}}" 
    lay-skin="switch" {{d.status==1?'checked':''}}  />
</script>

<!-- // 列表工具栏 -->
<script type="text/html" id="tableBar"> 
    <a class="layui-table-text" lay-title="{:__('编辑')} {{d.title}}" lay-area="680px" lay-url="#editforms" lay-event="edit" >{:__('编辑')}</a>
    <div class="layui-divider layui-divider-vertical"></div>
    <a class="layui-table-text"  lay-url="{:url('/system.pluginhook/del')}?id={{d.id}}" lay-event="del" >{:__('删除')}</a>
</script>
<include file="/public/footer" />
<script>
    layui.use(['table'], function () {

        var table = layui.table;
        /*
         * 初始化表格
        */
        var isTable = table.render({
            elem: "#lay-tableList"
            ,url: "{:url('/system.pluginhook/index')}"
            ,cols: [[
                {type: 'checkbox', width:45},
                {field: 'id', align: 'center',sort: true,width: 80,  title: 'ID'},
                {field: 'title', align: 'left', title: '{:__("事件名称")}'},
                {field: 'class', align: 'center',title: '{:__("事件类方法")}'},
                {field: 'trigger', align: 'center',  title: '{:__("触发位置")}'},                
                {field: 'sort', sort: true,align: 'center', title: '{:__("排序")}'},
                {field: 'status', align: 'center',templet: '#columnStatus', title: '{:__("状态")}'},
                {align: 'center', toolbar: '#tableBar', width:150, title: '{:__("操作")}'},
            ]]
        })
    })
</script>
